﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE.SQL.CUSTOM
{
    public class DBCMap
    {
        public static List<DBCMap> MapList = GetDBCMapList();

        public static void SaveDBCMapList()
        {
            var xml = Serializer.ToXml(MapList,  MapList.GetType());
            System.IO.File.WriteAllText("dbcmap.xml", xml);
        }

        private static List<DBCMap> GetDBCMapList()
        {
            if (!System.IO.File.Exists("dbcmap.xml")) return new List<DBCMap>();
            return (List<DBCMap>)Serializer.FromXml(System.IO.File.ReadAllText("dbcmap.xml"), typeof(List<DBCMap>));
        }

        public static DBCMap GetMapById(int id)
        {
            return PACKETPARSERMAX20.CORE.SQL.CUSTOM.DBCMap.MapList.Where(t => t.id == id).FirstOrDefault();
        }
        public int id { get; set; }
        public string name_internal { get; set; }
        public int map_type { get; set; }
        public string name { get; set; }
    }
}
